package com.probox.common.entity.service.order;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.extension.service.IService;
import com.probox.activity.api.domain.ActivityGiftVo;
import com.probox.activity.api.domain.ActivityInfoQuery;
import com.probox.common.core.web.page.TableDataInfo;
import com.probox.common.entity.domain.order.OrderExport;
import com.probox.common.entity.domain.order.OrderInfo;
import com.probox.common.entity.domain.order.OrderInfoItem;
import com.probox.common.entity.domain.order.OrderInvoice;
import com.probox.common.entity.domain.order.vo.OrderMergeDetailVo;
import com.probox.common.entity.domain.order.vo.OrderSettlementVo;
import com.probox.common.entity.vo.system.WorkOrderDetailVo;
import com.probox.common.entity.vo.system.WorkOrderVo;
import com.probox.customer.api.domain.CustomerGroupDefinitionQuery;
import com.probox.order.api.domain.*;
import com.probox.product.api.domain.ProductOptVo;

import java.util.List;
import java.util.Map;

/**
 * 订单子Service接口
 *
 * @author usoft
 * @date 2021-05-27
 */
public interface IOrderInfoService extends IService<OrderInfo> {

    /**
     * 自提发货
     *
     * @param orderInfo
     * @return
     */
    public boolean ziTiOrderInfo(OrderInfo orderInfo);

    /**
     * 订单开票中心
     *
     * @param info
     * @return
     */
    public List<OrderInfo> selectListByInvoice(OrderInfo info);

    public JSONObject addPayInfo(OrderInfo orrderInfo, OrderInfoItem or);

    /**
     * 收款接口
     */
    public boolean collection(OrderInfo info);

    public boolean renGongDaZhe(OrderInfo info);

    /**
     * 查询订单详情
     *
     * @param orderId
     * @return
     */
    public WorkOrderDetailVo getWorkOrderDetailVo(Long orderId);

    /**
     * 帮客户在后台创建菜单
     *
     * @param vo
     */
    public OrderInfo createOrderByPC(WorkOrderVo vo);

    /**
     * 查询用户消费了多少
     *
     * @param customerUid
     * @return
     */
    public String getOrderAmountByUid(Long customerUid);

    /**
     * 查询订单子
     *
     * @param orderUid 订单子ID
     * @return 订单子
     */
    public OrderInfoVo selectOrderInfoById(Long orderUid);


    /**
     * 查询订单子列表
     *
     * @param orderInfo 订单子
     * @return 订单子集合
     */
    public List<OrderInfo> queryList(OrderInfo orderInfo);

    public OrderInfo sumQueryList(OrderInfo orderInfo);

    public List<OrderExport> exportList(OrderInfo orderInfo);

    public TableDataInfo exportOrderDataInfo(OrderInfo orderInfo);


    /**
     * 新增订单子
     *
     * @param orderInfo 订单子
     * @return 结果
     */
    public boolean insertOrderInfo(OrderInfo orderInfo);

    /**
     * 保存后台订单
     * @param orderInfo
     * @return
     */
    public boolean saveAdminOrderInfo(OrderInfo orderInfo);

    /**
     * 修改订单子
     *
     * @param orderInfo 订单子
     * @return 结果
     */
    public boolean updateOrderInfo(OrderInfo orderInfo);

    /**
     * 批量删除订单子
     *
     * @param orderUids 需要删除的订单子ID
     * @return 结果
     */
    public boolean deleteOrderInfoByIds(Long[] orderUids);

    /**
     * 查询未结算的订单
     *
     * @param itemApi
     * @return
     */
    public List<com.probox.order.api.domain.OrderSettlementVo> getBySettlement(ItemSettlementVo itemApi);

    /**
     * 根据ID获取订单信息
     *
     * @param orderIds
     * @return
     */
    public List<com.probox.order.api.domain.OrderSettlementVo> getOrderById(Long[] orderIds);

    /**
     * 创建订单
     *
     * @param settle
     * @return
     * @throws Exception
     */
    public JSONObject createOrder(OrderSettlementVo settle) throws Exception;

    public JSONObject editOrder(OrderSettlementVo settle) throws Exception;

    /**
     * 创建兑换订单
     *
     * @param settle
     * @return
     * @throws Exception
     */
    public JSONObject createExchangeOrder(OrderSettlementVo settle) throws Exception;

    /**
     * 预下单
     *
     * @param settle
     * @return
     * @throws Exception
     */
    public Map<String, Object> preCreateOrder(OrderSettlementVo settle) throws Exception;

    public Map<String, Object> preEditOrder(OrderSettlementVo settle) throws Exception;

    /**
     * 微信支付回调
     *
     * @param jsonObject
     * @return
     */
    public boolean wechatPaymentCallBack(JSONObject jsonObject);

    /**
     * 我的订单列表
     *
     * @param query
     * @return
     */
    List<OrderInfoVo> selectOrder(OrderQuery query);

    /**
     * 订单总条数
     *
     * @param query
     * @return
     */
    Integer selectOrderCount(OrderQuery query);

    /**
     * 修改用户收货地址
     *
     * @param query
     * @return
     */
    boolean updateAddress(OrderQuery query);

    /**
     * 修改订单发票
     *
     * @param query
     * @return
     */
    boolean updateInvoice(OrderQuery query);

    /**
     * 取消订单
     *
     * @param query
     * @return
     */
    boolean orderCancel(OrderQuery query);

    /**
     * 订单收货
     *
     * @param query
     * @return
     */
    boolean receiveOrder(OrderQuery query);

    /**
     * 订单延迟收货
     *
     * @param query
     * @return
     */
    boolean delayReceive(OrderQuery query);

    /**
     * 订单评价
     *
     * @param query
     * @return
     */
    boolean orderComment(OrderQuery query);

    boolean orderFinish(OrderQuery query);

    /**
     * 订单物流信息
     *
     * @param query
     * @return
     */
    OrderTraceVo getTraceInfo(OrderQuery query);


    /**
     * 继续支付
     *
     * @param settle
     * @return
     */
    public JSONObject toPay(OrderSettlementVo settle);

    /**
     * 根据商品ID查询未付款订单及其他子订单
     *
     * @param query
     * @return
     */
    List<OrderMergeDetailVo> getOrderByProId(OrderQuery query);

    /**
     * 砍价订单
     *
     * @param query
     * @return
     */
    boolean addBargainOrder(ActivityInfoQuery query);

    boolean updateBargainOrder(ActivityInfoQuery query);

    /**
     * 购买会员
     *
     * @param settle
     * @return
     */
    JSONObject buyVip(OrderSettlementVo settle);

    /**
     * 充值
     *
     * @param settle
     * @return
     */
    JSONObject toRecharge(OrderSettlementVo settle);

    JSONObject rechargeMoney(OrderSettlementVo settle);

    /**
     * 统计代办订单
     *
     * @param customerUid
     * @return
     */
    OrderCountVo orderCount(Long customerUid);

    /**
     * 撤销发货
     *
     * @param query
     * @return
     */
    boolean revokeShip(OrderQuery query);

    /**
     * 取消发货
     *
     * @param query
     * @return
     */
    boolean cancelShip(OrderQuery query);

    void v3ProfitsharingOrdersUnfreeze(String subMchid, String transactionId, String orderNo);

    /**
     * 获取打单模板
     *
     * @param orderUid
     * @return
     */
    String getTemplate(Long orderUid) throws Exception;


    /**
     * 操作日志
     *
     * @param key
     * @param platformUid
     * @param customerUid
     * @param proUid
     * @param serviceNumber
     */
    void sendLogMsg(String key, Long platformUid, Long customerUid, String proType, Long proUid, Long serviceNumber);

    /**
     * 添加备注
     *
     * @param query
     * @return
     */
    JSONArray addRemark(OrderQuery query);

    /**
     * 开票
     *
     * @param invoice
     * @return
     */
    boolean addInvoice(OrderInvoice invoice);

    /**
     * 订单编号模糊搜索
     *
     * @param query
     * @return
     */
    List<Long> getOrderUidByNo(OrderQuery query);

    /**
     * 有效时间内，支付成功订单数
     *
     * @param query
     * @return
     */
    List<ProductOptVo> getOrderCount(CustomerGroupDefinitionQuery query);

    /**
     * 生成赠品订单
     *
     * @param vo
     * @return
     */
    Long giftOrder(ActivityGiftVo vo);

    boolean checkOrder(Long customerId);

    public void testAddWeiXinProfitReceiver();
}
